package Draw0513;

import java.awt.*;
import java.awt.geom.Point2D;

public class FractalShape extends ShapeV2{
    public FractalShape(Color color){
        this.color = color;
    }
    private static final int MAX_ITERATIONS = 200000;
    private static final double a = 1.641, b = 1.902, c = 0.316, d = 1.525;
    private Point2D.Double initPoint = new Point2D.Double(0.0,0.0);
    Graphics g;

    public void drawFractal(Graphics g){
        Graphics2D g2d = (Graphics2D) g;
        Point2D.Double currentPoint = new Point2D.Double(initPoint.x, initPoint.y);
        for (int i = 0; i < MAX_ITERATIONS; i++) {
            double nextX = Math.sin(a * currentPoint.y) - Math.cos(b * currentPoint.x);
            double nextY = Math.sin(c * currentPoint.x) - Math.cos(d * currentPoint.y);

            g2d.drawLine((int) (currentPoint.x * 100 + 400), (int) (currentPoint.y * 100 + 400),
                    (int) (currentPoint.x * 100 + 400), (int) (currentPoint.y * 100 + 400));

            currentPoint.x = nextX;
            currentPoint.y = nextY;
        }
    }




}
